﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer
{
    public class EmailSender
    {
    
        public void sendEmail(String ToAddress,String Subject,String body)
        {
            //EnsureCurrentlyValid();
            // Send via email

            //var message = new StringBuilder();
            //message.AppendFormat("Date: {0:yyyy-MM-dd hh:mm}\n", DateTime.Now);
            //message.AppendFormat("Email from: {0}\n", "Ayyappan");
            //message.AppendFormat("Email: {0}\n", "uclgadgeteer");
            //message.AppendFormat("Message: {0}\n", "Hi");

            SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
            smtpClient.EnableSsl=true;
            smtpClient.UseDefaultCredentials = true;
            smtpClient.Credentials = new System.Net.NetworkCredential("uclgadgeteer", "gadg3t33r");
            MailMessage m = new MailMessage(
                "uclgadgeteer@gmail.com", // From
                ToAddress, // To
                Subject, // Subject
                body); // Body

            smtpClient.Send(m);
        }
    }
}
 